﻿#region License
// (c) Garry McGlennon 2009
// 
// This project is made available under the Microsoft Public License (Ms-PL)
// Code is provided as is and with no warrenty – Use at your own risk
// 
// View the project and the latest code at http://dnpframework.codeplex.com/
// 
// All other rights reserved.
// 
// blog: www.dotNetProfessional.com/blog/
#endregion

using dnp.ServiceModel.Configuration;

namespace dnp.ServiceModel
{
    public class MetaData
    {
        private EntityMetaData _entity;
        private ServiceMetaData _service;
        private ServiceDomainMetaData _serviceDomain;
        private UnitTestMetaData _unitTest;

        private dnpModel _model;
        private MetaDataDefinition _definition;

        public MetaData(dnpModel model, MetaDataDefinition definition)
        {
            _model = model;
            _entity = new EntityMetaData(definition.Entity, model);
            _service = new ServiceMetaData(definition.Service, model);
            _serviceDomain = new ServiceDomainMetaData(definition.ServiceDomain, model);
            _unitTest = new UnitTestMetaData(definition.UnitTest, model);
            _definition = definition;
        }

        public EntityMetaData Entity
        {
            get { return _entity; }
            set { _entity = value; }
        }

        public ServiceMetaData Service
        {
            get { return _service; }
            set { _service = value; }
        }

        public UnitTestMetaData UnitTest
        {
            get { return _unitTest; }
            set { _unitTest = value; }
        }

        public ServiceDomainMetaData ServiceDomain
        {
            get { return _serviceDomain; }
            set { _serviceDomain = value; }
        }

        public ServiceMethodMetaData<T> ServiceMethods<T>(T source, ServiceFeatureEnum serviceMethodFeature)
        {
            return new ServiceMethodMetaData<T>(source, serviceMethodFeature,_definition.ServiceMethods, _model);
        }
    }
}
